package com.liangzi.service_core.controller;


import com.liangzi.liangzi_common.result.R;
import com.liangzi.service_core.pojo.entity.SysDictData;
import com.liangzi.service_core.service.SysDictDataService;
import com.liangzi.servicebase.util.RedisUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 字典数据表 前端控制器
 * </p>
 *
 * @author zhj
 * @since 2021-12-13
 */
@Api(description = "数据字典接口")
@RestController
@RequestMapping("/web/sysDictData")
public class SysDictDataController {


    @Autowired
    public SysDictDataService sysDictDataService;

    @Autowired
    private RedisUtil redisUtil;

    // 根据数据id查询子数据列表
    @ApiOperation(value = "获取所有门诊")
    @GetMapping("getOutpatientList/{rdSession}")
    public R getOutpatientList(
            @PathVariable("rdSession") String rdSession
    ) {
        // 判断是否登录
        String userId = (String) redisUtil.get("session:" + rdSession);
        if (userId == null) {
            return R.error().message("请重新登录");
        }
        List<SysDictData> list = sysDictDataService.getOutpatientByDictType();

        return R.ok().data("records", list);
    }


    // 获取所有的预约状态
    // 根据数据id查询子数据列表
    @ApiOperation(value = "获取所有门诊")
    @GetMapping("getBookingStatus/{rdSession}")
    public R getBookingStatus(
            @PathVariable("rdSession") String rdSession
    ) {
        // 判断是否登录
        String userId = (String) redisUtil.get("session:" + rdSession);
        if (userId == null) {
            return R.error().message("请重新登录");
        }
        List<SysDictData> list = sysDictDataService.getBookingStatusByDictType();


        return R.ok().data("records", list);
    }


}

